#ifndef __STOCKSERVICE_H__
#define __STOCKSERVICE_H__


#include "stdafx.h"
#include "Security.h"
#include "FCPaint.h"
#include "SecurityData.h"

/*
 * 股票服务
 */
class StockService{
public:
    /*
     * 获取指定年月日的星期
     *@param year 年
     *@param month 月
     *@param day 日
     */
    static int dayOfWeek(int y, int m, int d);
    /*
     * 获取季度
     */
    static int getSeason(int month);
    /*
     * 合并最新数据
     *@param oldDatas 老数据
     *@param latestData 新数据
     *@param tickDataCache TICK数据
     *@param cycle 周期
     */
    static void mergeLatestData(String code, ArrayList<SecurityData> *oldDatas, SecurityData latestData, ClientTickDataCache *tickDataCache, int dCycle);
    static double fq_price_func(double price, ADJUSTMENTFACTOR *factor);
    static double fq_price_func2(double price, ADJUSTMENTFACTOR *factor);
    /*
     * 转换前复权
     *@param code
     *@param kd
     */
    static void ConvertXDRBeforePrice(String code, SecurityData *kd, double trade_date, ArrayList<ADJUSTMENTFACTOR*> *factor);
    /*
     * 转换后复权
     *@param code
     *@param kd
     */
    static void ConvertXDRAfterPrice(String code, SecurityData *kd, double trade_date, ArrayList<ADJUSTMENTFACTOR*> *factor);
    static void ConvertXDR(String code, int rights_offering, ArrayList<SecurityData> *datas);
    static void multiMinuteSecurityDatas(ArrayList<SecurityData> *newDatas, ArrayList<SecurityData> *minuteDatas, int cycle);
    static int getHistoryWeekDatas(ArrayList<SecurityData> *weekDatas, ArrayList<SecurityData> *dayDatas);
    static int getHistoryMonthDatas(ArrayList<SecurityData> *monthDatas, ArrayList<SecurityData> *dayDatas);
    static int getHistorySeasonDatas(ArrayList<SecurityData> *seasonDatas, ArrayList<SecurityData> *dayDatas);
    static int getHistoryHalfYearDatas(ArrayList<SecurityData> *halfYearDatas, ArrayList<SecurityData> *dayDatas);
    static int getHistoryYearDatas(ArrayList<SecurityData> *yearDatas, ArrayList<SecurityData> *dayDatas);
};


#endif
